<template>
    <div class="about">
		<!-- <banner isHome="true"></banner> -->
        <div class="site-content">
            <div class="content-warp">
                <div class="about-me about-info">
                    <section-title id="Guestbook"><span>❤</span>我参加的比赛</section-title>
                    <div class="info-card" v-for="item in race">
                        <div class="contactForm">
							<div class="focusinfo">
							    <img :src="item.src">
							</div>
							<ul class="list-group list-group-striped">
								<li class="list-group-item">
									比赛标题:{{item.title}}
								</li>
								<li class="list-group-item">
									比赛详情:{{item.description}}
								</li>
								<li class="list-group-item">
									开始时间:{{item.startTime}}
								</li>
								<li class="list-group-item">
									结束时间:{{item.endTime}}
								</li>
								<li v-if="item.limit===1" class="list-group-item">
									剩余名额:{{item.limitedNum}}
								</li>
								<li v-if="item.limit===0" class="list-group-item">
									无人数限制
								</li>
								<li class="list-group-item" v-if="item.isStart===0" style="color: red;">
									未开始
								</li>
								<li class="list-group-item" v-if="item.isStart===2" style="color: red;">
									已结束
								</li>
								<button style="margin-top: 10px;" v-if="item.isStart!==2" @click="come(item.id)">退出比赛</button>
							</ul>
                        </div>
                    </div>

					<div class="more" v-show="hasNextPage">
						<div class="more-btn" @click="loadMore">More</div>
					</div>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
	import sectionTitle from '@/components/section-title'
	import { getUserRace, quitRaceById } from '@/api/race'
    export default {
        name: "About",
        data() {
            return {
				race: [],
				currPage: 1,
				hasNextPage: true,
				raceId: ''
            }
        },
        components: {
			sectionTitle
            // Quote,
        },
        methods: {
			async get() {
				let data = await getUserRace({
					pageNum: this.currPage,
					pagesize: 5
				})
				this.race = data.race
			},
			async loadMore() {
				this.currPage = this.currPage + 1
				let data = await getUserRace({
					pageNum: this.currPage,
					pagesize: 5
				})
				this.race = this.race.concat(data.race || [])
			},
			async come(id) {
				let data = await quitRaceById(id)
				alert(data.msg)
				this.get()
			}
		},
        mounted() {
			this.currPage = 1
			this.get()
        }
    }
</script>

<style scoped lang="less">
    .about {
        padding-top: 40px;
    }

	.list-group-striped > .list-group-item {
		border-left: 0;
		border-right: 0;
		border-radius: 0;
		padding-left: 0;
		padding-right: 0;
	}
	.list-group-item {
		border-bottom: 1px solid #e7eaec;
		border-top: 1px solid #e7eaec;
		margin-bottom: -1px;
		padding: 11px 0;
		font-size: 13px;
	}
	.pull-right {
		float: right !important;
	}
	.focusinfo {
	    position: relative;
	    max-width: 800px;
	    padding: 0 10px;
	    top: 40%;
	    left: 50%;
	    transform: translate(-50%,-50%);
	    -webkit-transform: translate(-50%,-50%);
	    text-align: center;
	    img {
			margin-top: 100px;
	        width: 80px;
	        height: 80px;
	        border-radius: 50%;
	        border: 3px solid rgba(255, 255, 255, 0.3);
	    }
	}

	.more{
	    margin: 50px 0;
	    .more-btn{
	        width: 100px;
	        height: 40px;
	        line-height: 40px;
	        text-align: center;
	        color: #ADADAD;
	        border: 1px solid #ADADAD;
	        border-radius: 20px;
	        margin: 0 auto;
	        cursor: pointer;
	        &:hover{
	            color: #8fd0cc;
	            border: 1px dashed #8fd0cc;
	        }
	    }
	}


    .content-warp {
        margin-top: 80px;

        .about-info {
            margin: 30px 0;

            span {
                color: red;
                margin-right: 10px;
            }

            .info-card {
                min-height: 100px;
                padding: 20px;
                border-radius: 3px;
                margin: 30px 0 50px 0;
                box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
                p{
                    line-height: 1.7rem;
                }
            }
        }
        .contactForm{
			text-align: center;
            width: 100%;
            padding: 20px;
            .form-item{
                align-items: center;
                display: flex;
                &:not(:last-child){
                    margin-bottom: 20px;
                }
                label{
                  width: 80px;
                }
                .v{
                    min-height: 40px;
                    line-height: 20px;
                    border-radius: 3px;
                    padding: 2px 10px;
                    outline:none;
                    border: 1px solid #8fd0cc;
                    width: 100%;
                    resize: vertical;
                }
                button{
                    width: 100px;
                    height: 40px;
                    border-radius: 3px;
                    outline:0;
                    border-style: none;
                    cursor: pointer;
                    background-color: #409eff;
                    color: white;
                    &:hover{
                        opacity: 0.8;
                    }
                }
            }
        }
    }

    /*******/
    @media (max-width: 800px) {
        .content-warp {
            margin-top: 0;
        }
    }
</style>
